<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>ajax学习</title>
</head>

<body>
    <div id="div1">
        haha
    </div>
    <input type="button" onclick="fresh()">
</body>

<script>
    function fresh() {
        let xmlHttpRequest = new XMLHttpRequest();
        xmlHttpRequest.open("GET", "https://jsonplaceholder.typicode.com/todos/1")
        xmlHttpRequest.send();

        xmlHttpRequest.onreadystatechange = function () {
            if (xmlHttpRequest.readyState == 4 && xmlHttpRequest.status == 200) {
                document.getElementById("div1").innerHTML = xmlHttpRequest.responseText;
            }
        }
    }
</script>

</html>